package com.liren.imgtool.exception;

/**
 * @description: 错误处理类
 * @author: Mr.Wang
 * @create time: on 2019-10-18 14:48
 **/

public class ImgToolException extends Exception implements CommonError{

    private CommonError commonError;

    //直接接受EmBusinessErrior的传参，用于构造业务异常
    public ImgToolException(CommonError commonError) {
        super();
        this.commonError = commonError;
    }

    //接受自定义errMsg的方式构造业务异常
    public ImgToolException(CommonError commonError, String errMsg) {
        super();
        this.commonError = commonError;
        this.commonError.setErrMsg(errMsg);
    }

    @Override
    public int getErrCode() {
        return this.commonError.getErrCode();
    }

    @Override
    public String getErrMsg() {
        return this.commonError.getErrMsg();
    }

    @Override
    public CommonError setErrMsg(String errMsg) {
        this.commonError.setErrMsg(errMsg);
        return this;
    }
}
